package com.lx.serv.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lx.dao.AdminDao;
import com.lx.domain.admin;
import com.lx.serv.AdminServ;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AdminServImpl implements AdminServ {

    @Autowired
    private AdminDao adminDao;

    @Override
    public String getNameBytoken(String token) {
        LambdaQueryWrapper<admin> query = new LambdaQueryWrapper<admin>();
        query.eq(admin::getToken, token.substring(0, token.length()));
        admin result = adminDao.selectOne(query);
        if (result != null) {
            return result.getUsername();
        }
        return null;
    }
}
